package cn.sdormitory.wx.utils;

import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 封装data数据
 */
@Component
public class WeatherDataCreator {

    /**
     * 封装公众号推送data数据(审批结果模板)
     * @param thing1    学生姓名
     * @param const2    审批结果
     * @param thing3    申请人
     * @param time4     申请时间
     * @param success
     * @return
     */
    public Map<String, Object> createResultWeatherDataMap(String thing1,String const2,String thing3,
                                                           String time4) {
//        Map<String, Object> data = new HashMap<>();
//        Map<String,String> map1 = new HashMap<>();
//        map1.put("value",thing1);
//        data.put("thing1", map1);
//        Map<String,String> map2 = new HashMap<>();
//        map2.put("value",const2);
//        data.put("const2", map2);
//        Map<String,String> map3 = new HashMap<>();
//        map3.put("value",thing3);
//        data.put("thing3", map3);
//        Map<String,String> map4 = new HashMap<>();
//        map4.put("value",time4);
//        data.put("time4", map4);

        Map<String, Object> data = new HashMap<>();
        data.put("thing1", JSONObject.parse("{\"value\":\"" + thing1 + "\"}"));
        data.put("const2", JSONObject.parse("{\"value\":\"" + const2 + "\"}"));
        data.put("thing3", JSONObject.parse("{\"value\":\"" + thing3 + "\"}"));
        data.put("time4", JSONObject.parse("{\"value\":\"" + time4 + "\"}"));
        return data;
    }

    /**
     * 封装公众号推送data数据(学生申请请假模板)
     * @param thing2    申请人
     * @param thing4    教工姓名
     * @param thing1    学生姓名
     * @param time3     申请时间
     * @param success
     * @return
     */
    public Map<String, Object> createStudentWeatherDataMap(String thing2,String thing4,String thing1,
                                                    String time3) {
        Map<String, Object> data = new HashMap<>();
        data.put("thing2", JSONObject.parse("{\"value\":\"" + thing2 + "\"}"));
        data.put("thing4", JSONObject.parse("{\"value\":\"" + thing4 + "\"}"));
        data.put("thing1", JSONObject.parse("{\"value\":\"" + thing1 + "\"}"));
        data.put("time3", JSONObject.parse("{\"value\":\"" + time3 + "\"}"));
        return data;
    }

    /**
     * 封装学生到校离校公众号模板数据
     * @author alex
     * @param: thing2
     * @param: thing4
     * @param: thing1
     * @param: time3
     * @date 2024/9/27 14:42
     * @return
     */
    public Map<String, Object> createStudentLeaveDataMap(String thing2,String thing1,
                                                           String time3) {
        Map<String, Object> data = new HashMap<>();
        // 学生姓名
        data.put("short_thing1", JSONObject.parse("{\"value\":\"" + thing2 + "\"}"));
        // 时间
        data.put("time2", JSONObject.parse("{\"value\":\"" + time3 + "\"}"));
        // 状态
        data.put("short_thing4", JSONObject.parse("{\"value\":\"" + thing1 + "\"}"));
        return data;
    }
    
    public Map<String, Object> createDormitoryClockRecordDataMap(String thing4,String thing1,
                                                         String time3) {
        Map<String, Object> data = new HashMap<>();
        // 学生姓名
        data.put("thing4", JSONObject.parse("{\"value\":\"" + thing4 + "\"}"));
        // 寝室楼名称
        data.put("thing1", JSONObject.parse("{\"value\":\"" + thing1 + "\"}"));
        // 时间
        data.put("time3", JSONObject.parse("{\"value\":\"" + time3 + "\"}"));
        return data;
    }


    /**
     * 封装公众号推送data数据(宿舍卫生检查通知模板)
     * @param thing1 宿舍楼
     * @param character_string2 宿舍号
     * @param const3 检查结果：优秀，良，差
     * @return 数据参数map
     */
    public Map<String, Object> createDorHygieneWeatherDataMap(String thing1,String character_string2,String const3,String time4) {
        Map<String, Object> data = new HashMap<>();
        data.put("thing1", JSONObject.parse("{\"value\":\"" + thing1 + "\"}"));
        data.put("character_string2", JSONObject.parse("{\"value\":\"" + character_string2 + "\"}"));
        data.put("const3", JSONObject.parse("{\"value\":\"" + const3 + "\"}"));
        data.put("time4", JSONObject.parse("{\"value\":\"" + time4 + "\"}"));
        return data;
    }

    /**
     * 封装data数据 宿舍违纪检查通知模板
     * @author alex
     * @param: studentName
     * @param: formatDateTime
     * @date 2024/11/15 16:31
     * @return
     */
    public Map<String, Object> createViolationsDataMap(String thing3, String time1) {
        Map<String, Object> data = new HashMap<>();
        data.put("thing3", JSONObject.parse("{\"value\":\"" + thing3 + "\"}"));
        data.put("time1", JSONObject.parse("{\"value\":\"" + time1 + "\"}"));
        return data;
    }
    
    /**
     * 封装维修通知模板数据
     * @author alex
     * @param: thing3
     * @param: thing2
     * @param: time1
     * @date 2024/11/27 16:09
     * @return
     */
    public Map<String, Object> createMaintenanceDataMap(String thing2, String thing3,  String time1) {
        Map<String, Object> data = new HashMap<>();
        data.put("thing3", JSONObject.parse("{\"value\":\"" + thing3 + "\"}"));
        data.put("thing2", JSONObject.parse("{\"value\":\"" + thing2 + "\"}"));
        data.put("time1", JSONObject.parse("{\"value\":\"" + time1 + "\"}"));
        return data;
    }

    public Map<String,Object> createViolationPatrolData(String studentName, Date violationTime) {
        Map<String,Object> data = new HashMap<>();
        String violationTimeStr = DateUtil.formatDateTime(violationTime);
        data.put("thing3", JSONObject.parse("{\"value\":\"" + studentName + "\"}"));
        data.put("time1", JSONObject.parse("{\"value\":\"" + violationTimeStr + "\"}"));
        return data;
    }

}
